/*
 * @Author: Tendo 
 * @Date: 2021-09-22 10:59:15 
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @param {number[]} nums3
 * @param {number[]} nums4
 * @return {number}
 */

 var fourSumCount = function (nums1, nums2, nums3, nums4) {
    let map = new Map(),
        count = 0;
    for (let i = 0; i < nums1.length; i++) {
        for (let j = 0; j < nums2.length; j++) {
            var sum1 = nums1[i] + nums2[j];
            if (!map.has(sum1)) {
                map.set(sum1, 1);
            } else {
                map.set(sum1, map.get(sum1)+1);
            }
        }
    }
    for (let i = 0; i < nums3.length; i++) {
        for (let j = 0; j < nums4.length; j++) {
            var sum2 = nums3[i] + nums4[j];
            if (map.has(0-sum2)) {
                count += map.get(0-sum2);
            }
        }
    }
    return count;
};